<template>
  <div class="body-layout">
		<header class="top-header">
			<!-- 返回按钮 -->
      <a @click="$router.back(-1);" class="header-left"></a>
			<article class="header-middle">意见反馈</article>
		</header>
		<div class="marginTop44">
	    <div class="vf-suggest">
	      <textarea class="textarea" placeholder="感谢您的宝贵意见" v-model="feedContent"></textarea>
	      <button type="button" class="phone-btn" @click="handleSubmitClick">提 交</button>
	    </div>
		</div>
  </div>
</template>

<script>
  import util from '@/lib/util.js'

  export default {
    name: 'FeedBack',

    data() {
      return {
        feedContent: ''
      }
    },
    created: function () {
      util.vars.in_time = new Date().getTime();
    },
    methods: {
      getfeedContent() {
        if (this.feedContent.trim().length === 0) {
          this.$toast('请填写意见', {
            duration: '1000'
          })
        } else {
          let _that=this;
          util.ajax.post('feedback/post', util.jsonStringify({
            category_id: 1,
            content: this.feedContent
          })).then((res) => {
            if (res.code == 1) {
              //提交成功之后，清空内容
              _that.feedContent="";
              var that = this;
              this.$toast('提交成功', {
                duration: '1000'
              })
              setTimeout(function () {
                that.$router.push({
                  path: "/pages/UserCenter"
                })
              }, 1500)
            } else {
              this.$toast(res.msg, {
                duration: '1000'
              })
            }
          });
        }
      },
      handleSubmitClick() {
        this.getfeedContent();
      }
    },
    mounted() {
    }
  }
</script>
